package com.hancai.service.impl;

import com.hancai.mapper.TActivityRemarkMapper;
import com.hancai.model.TActivity;
import com.hancai.model.TActivityRemark;
import com.hancai.query.ActivityRemarkQuery;
import com.hancai.service.ActivityRemarkService;
import com.hancai.util.JWTUtils;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author 涵菜
 * @version 1.0
 */
@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {

    @Resource
    private TActivityRemarkMapper tActivityRemarkMapper;

    @Override
    public Integer saveActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
        TActivityRemark tActivityRemark = new TActivityRemark();
        BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);
        tActivityRemark.setCreateTime(new Date());
        Integer loginUserId = JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId();
        tActivityRemark.setCreateBy(loginUserId);
        return tActivityRemarkMapper.insertSelective(tActivityRemark);
    }
}
